using ParadoxNotion.Design;
using UnityEngine;
using Yoozoo.Gameplay.Liberty.Nodes;

namespace Yoozoo.Gameplay.Liberty.AI.Node
{
    [Category("Ggame/Liberty")]
    public class GotoEventPosition : AIBaseNode
    {
        protected AIData aiData;

        protected override void OnExecute()
        {
            aiData = _entity.data;
            _entity.seeker.SwitchSpeedStrategy(aiData.speedStrategy);
            base.SetMaxSpeed(aiData.maxSpeed);
            base.SetPosition(aiData.position);
            base.SetRotation(aiData.rotation);
            base.SetDestination(aiData.eventPosition);
        }

        protected override void OnUpdate()
        {
            SetTransformData();
            if (_entity.seeker.ReachedEndOfPath() || _entity.seeker.aiPath.maxSpeed <= 0.01f)
            {
                TriggerNpcBehavior.OnReachedEventPos?.Invoke(aiData.uniqueId,aiData.eventPosition);
                EndAction(true);
            }
        }
    }
}